load("@fbsource//tools/build_defs:rust_binary.bzl", "rust_binary")
load("//registry:defs.bzl", "rpm")

oncall("scm_server_infra")

rust_binary(
    name = "scsc",
    srcs = glob(["src/**/*.rs"]),
    allow_oss_build = False,
    os_deps = [
        (
            "linux",
            [
                "//common/rust/build_info:build_info",
                "//common/rust/thrift/srclient:srclient",
                "//tupperware/api/if:common-rust",
                "//tupperware/api/if:tupperware-rust",
                "//tupperware/api/if:tupperware-rust-srclients",
            ],
        ),
        (
            "macos",
            [
                "//common/rust/build_info:build_info",
            ],
        ),
    ],
    test_deps = [
        "//eden/mononoke/mononoke_macros:mononoke_macros",
    ],
    deps = [
        "fbsource//third-party/rust:ansi_term",
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:async-tar",
        "fbsource//third-party/rust:async-trait",
        "fbsource//third-party/rust:auto_impl",
        "fbsource//third-party/rust:bytesize",
        "fbsource//third-party/rust:chrono",
        "fbsource//third-party/rust:clap",
        "fbsource//third-party/rust:faster-hex",
        "fbsource//third-party/rust:futures",
        "fbsource//third-party/rust:itertools",
        "fbsource//third-party/rust:lazy_static",
        "fbsource//third-party/rust:maplit",
        "fbsource//third-party/rust:num",
        "fbsource//third-party/rust:serde",
        "fbsource//third-party/rust:serde_json",
        "fbsource//third-party/rust:strum",
        "fbsource//third-party/rust:textwrap",
        "fbsource//third-party/rust:tokio",
        "fbsource//third-party/rust:tokio-stream",
        "fbsource//third-party/rust:tokio-util",
        "fbsource//third-party/rust:unicode-truncate",
        "fbsource//third-party/rust:unicode-width",
        "//common/rust/cpp_log_spew:cpp_log_spew",
        "//common/rust/gflags:gflags",
        "//common/rust/shed/bounded_traversal:bounded_traversal",
        "//common/rust/shed/cloned:cloned",
        "//common/rust/shed/fbinit:fbinit",
        "//common/rust/shed/fbinit:fbinit-tokio",
        "//common/rust/shed/hostcaps:hostcaps",
        "//eden/mononoke/cmdlib/base_app:base_app",
        "//eden/mononoke/cmdlib/commit_id_types:commit_id_types",
        "//eden/mononoke/common/topo_sort:topo_sort",
        "//eden/mononoke/scs/if:source_control-rust",
        "//eden/mononoke/scs/if:source_control-rust-clients",
        "//eden/mononoke/scs/raw_client_lib:scs_client_raw",
    ],
)

rpm.builder(
    name = "fb-scsc",
    configurations = [
        rpm.configuration(arch = "x86_64"),
        rpm.configuration(arch = "aarch64"),
    ],
    features = [
        rpm.install(
            src = ":scsc",
            dst = "/usr/local/bin/scsc",
        ),
    ],
    summary = "Source Control Service Client",
)
